<template>
 <rx-layout>
   <div slot="header" >
        <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="48">
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.portalID','门户ID')">
                        <a-input :placeholder="i18n('form.portalID','门户ID','input')" v-model="queryParam.Q_LAYOUT_ID__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="$ti18('rxForm.type', '类型')">
                        <a-input :placeholder="$ti18('rxForm.type', '类型','select')" v-model="queryParam.Q_TYPE__S_LK"/>
					</a-form-item>
				  </a-col>
				  <a-col :md="5" :sm="15">
					<a-form-item :label="i18n('form.groupID','用户或组ID')">
                        <a-input :placeholder="i18n('form.groupID','用户或组ID','input')" v-model="queryParam.Q_OWNER_ID__S_LK"/>
					</a-form-item>
				  </a-col>
		  <template v-if="advanced">
			<!--TODO add advance search field here -->
          </template>

          <a-col :md="8" :sm="24">
            <span class="table-page-search-submitButtons">
              <a-button type="primary" @click="$refs.table.refresh(true)" icon="search">{{$ti18('rxList.searchBtn','查询')}}</a-button>
              <a-button style="margin-left: 4px" @click="resetSearch">{{$ti18('rxList.resetBtn', '重置')}}</a-button>
              <a @click="toggleAdvanced" style="margin-left: 8px">
                  {{ advanced ? $ti18('rxList.putAwayBtn','收起') : $ti18('rxList.openBtn','展开') }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
        </div>
        <div slot="center" style="">
           <div class="table-operator">
      <a-button  type="primary" icon="plus" @click="add">{{$ti18('rxList.newBtn',"新建")}}</a-button>
      <a-button v-if="editEnable && selectedRowKeys.length > 0" type="primary" icon="edit" @click="editOne">{{$ti18('rxList.editBtn',"编辑")}}</a-button>
      <a-dropdown v-if="removeEnable && selectedRowKeys.length > 0">
        <a-button type="danger" icon="delete" @click="delByIds(selectedRowKeys)">{{$ti18('rxList.delBtn','删除')}}</a-button>
      </a-dropdown>
      <span style="float:right">
         <a-button type="primary" shape="circle"  icon="sync" :size="small" @click="refreshGrid"></a-button>
         <a-button type="primary" shape="circle"  icon="search" :size="small" @click="toggleSearch"></a-button>
       </span>
    </div>
    <s-table
      size="default"
      ref="table"
      rowKey="id"
      bordered
      :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
      :columns="columns"
      :data="loadData">
	 <span slot="serial" slot-scope="text, record, index">
		{{ index + 1 }}
	 </span>
      <span slot="action" slot-scope="text, record" class="actionIcons">
        <span v-if="editEnable" @click="edit(record)">{{$ti18('rxList.editBtn',"编辑")}}</span>
        <span v-if="removeEnable" @click="delByIds([record.id])">{{$ti18('rxList.delBtn','删除')}}</span>
      </span>
    </s-table>
        </div>

 </rx-layout>
</template>

<script>
  import InsPortalPermissionApi from '@/api/portal/core/insPortalPermission'
  import InsPortalPermissionEdit from './InsPortalPermissionEdit'
  import {BaseList,RxDialog} from "@lowcode/jpaas-common-lib";
  export default {
    name: 'InsPortalPermissionList',
    mixins:[BaseList],
    components: {
      RxDialog
    },
    data () {
      return {
        columns: [
          {title: '#',scopedSlots: { customRender: 'serial' },width: 30},
          { title: this.i18n('form.portalID','门户ID'),dataIndex: 'layoutId', },
          { title: this.$ti18('rxForm.type', '类型'),dataIndex: 'type'},
          { title: this.i18n('form.groupID','用户或组ID'),dataIndex: 'ownerId' },
          {title: this.$ti18('rxList.action','操作'), width: '220px', dataIndex: 'action', scopedSlots: {customRender: 'action'}}
        ],
        component:InsPortalPermissionEdit,
        comment:this.i18n('list.layoutSet','布局权限设置'),
        widthHeight:['800px','600px']
      }
    },
    methods:{
        i18n(name,text,key){
            return this.$ti18(name,text,"InsRemindDef",key);
        },
      delById(ids){
        return InsPortalPermissionApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return InsPortalPermissionApi.query(parameter)
      }
    }
  }
</script>
<style scoped>

</style>

